package com.flyduck.system.vo.dept.trans;


import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil;
import com.flyduck.system.entity.SysDeptEntity;
import com.flyduck.system.vo.dept.SysDeptAddReqVO;
import com.google.common.base.Function;


/**
 * @program: flyduck-platform
 * @description:
 * @author: flyduck
 * @create: 2021-02-01 12:42
 **/
public class SysDeptAddReqVOToSysDeptEntity implements Function<SysDeptAddReqVO, SysDeptEntity> {

    @Override
    public SysDeptEntity apply(SysDeptAddReqVO reqVO) {
        SysDeptEntity deptEntity = new SysDeptEntity();
        BeanUtil.copyProperties(reqVO,deptEntity);
        deptEntity.setId(Long.valueOf(reqVO.getId()));
        if(ObjectUtil.isNotNull(reqVO.getParentId())){
            deptEntity.setParentId(Long.valueOf(reqVO.getParentId()));
        }
        deptEntity.setSort(Integer.valueOf(reqVO.getSort()));
        return deptEntity;
    }
}
